<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- **内联事件处理器** -->
      <p>{{ count }}</p>
      <button v-on:click="count++">btn1</button>

      <!-- **方法事件处理器** -->
      <p>{{ num }}</p>
      <button v-on:click="handleClick">btn</button>

      <hr />

      <!-- 事件对象 -->
      <!-- 方法事件处理器不能加括号 -->
      <!-- 在有括号的情况下，我们需要主动传入实参$event -->
      <button v-on:click="logEvent(8, $event)">打印事件对象</button>
      <button v-on:click="logEvent2">打印事件对象2</button>

      <hr />

      <button v-on:click="logNum(2)">传入2</button>
      <button v-on:click="logNum(3)">传入3</button>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            count: 1,
            num: 3,
          };
        },
        methods: {
          handleClick() {
            this.num++;
          },
          logEvent(num, event) {
            console.log(num, event);
          },
          logEvent2() {
            console.log(event);
          },
          logNum(n) {
            console.log(n);
          },
        },
        // 相当于window.onload
        // mounted() {
        //   // console.log(123);
        //   this.handleClick();
        // },
      }).mount("#app");
    </script>
  </body>
</html>
